package com.window;

import com.event.ChangeInfoEvent;
import javax.swing.*;
import java.awt.*;

public class ChangeAccountInfo extends JFrame
{
    FlowLayout flowlayout;
    JLabel name,password,account;
    public  static  JTextField nametext,accounttext;
    public  static JPasswordField passwordtext;
    JButton change;
    final int WIDTH=250;//框架宽度
    final int HEIGHT=170;//框架高度

    public ChangeAccountInfo()
    {
        super("员工信息更改");
        init();
        setVisible(true);//设置窗口可视化
        setResizable(false);//设置窗口大小不可变
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);//设置默认关闭方式
        validate();//让组件生效
        allevent();
    }
    void init()
    {
        flowlayout = new FlowLayout(FlowLayout.CENTER);//布局居中
        this.setLayout(flowlayout);
        //设置窗口大小与位置
        Toolkit kit = Toolkit.getDefaultToolkit();
        Dimension screenSize = kit.getScreenSize();
        int width = screenSize.width;
        int height = screenSize.height;
        int x = (width - WIDTH) / 2;
        int y = (height - HEIGHT) / 2;
        this.setBounds(x, y, WIDTH, HEIGHT);//设置窗口位置与大小

        Font f = new Font("宋体",Font.BOLD,18);//初始化字体
        account=new JLabel("账号  ");
        account.setFont(f);
        name=new JLabel("新姓名");
        name.setFont(f);
        password=new JLabel("新密码");
        password.setFont(f);
        accounttext=new JTextField(15);
        nametext=new JTextField(15);
        passwordtext=new JPasswordField(15);//初始化
        change=new JButton("更改员工信息");
        change.setFont(f);

        //添加操作
        this.add(account);
        this.add(accounttext);
        this.add(name);
        this.add(nametext);
        this.add(password);
        this.add(passwordtext);
        this.add(change);
    }

    //创建监听
    void allevent()
    {
        ChangeInfoEvent a=new ChangeInfoEvent();
        change.addActionListener(a);
    }
}
